<?php
if (!defined('IN_WONDERSHARE'))
{
	die('Hacking attempt');
}
class ArticleModule 
{
   var $db;
   var $str = '';
   function __construct()
   {
   	$this->db = $GLOBALS['db'];
   }
   function get_article_info($sql,$type = '')
   { 
   	$date = array();
	$result = $this->db->query($sql);
	if($type == 'related')
	{
	 while($row = $this->db->fetch_array($result))
	 {

	 $date[] = $row;
	 }	
	}else
	{

	 while($row = $this->db->fetch_array($result))
	 {
	 $row['pub_time'] = $row['pub_time'] == 0 ?'':date('Y-m-d H:i',$row['pub_time']);
	 $row['update_time'] = $row['update_time'] == 0 ?'':date('Y-m-d H:i',$row['update_time']);
	 $date[] = $row;
	 }
	}
	return  $date;
   }
   function  change_info($sql)
   {
   	$affect = $this->db->query($sql);
   	return  $affect;
   }
   function  get_sub_category($sql)
   {
   	$str = '';
	$result = $this->db->query($sql);
	while($row = $this->db->fetch_array($result))
	{
	 $str.= $row['cat_id'].',';
	}
	return  $str;
   }
   
   function getarticlebyid($sql)
   {
   		if($sql)
   		{
   			return $GLOBALS['db']->getOne($sql);
   		}
   		return false;
   }
   
   function getarticlebyidt($sql)
   {
   		if($sql)
   		{
   			return $GLOBALS['db']->getRow($sql);
   		}
   		return false;
   }
}

?>